Skip to content

Support range sequences in index_of - #455

Merged
dgilland merged 2 commits into
dgilland:developfrom
Gambit-Checkmate:fix/index-of-range-start
Nov 15, 2026
Merged

dgilland merged 2 commits into
dgilland:developfrom
Gambit-Checkmate:fix/index-of-range-start

Conversation

@Gambit-Checkmate

Copy link
Copy Markdown
Contributor

Change

index_of passes a start argument to the sequence's index method. Python's range.index takes only a value, so every range lookup previously raised TypeError. Slice the range at the requested start, use its native lookup, and translate a match back to its original index. Range slicing preserves constant space and the native arithmetic lookup for integer values.

Fixes #454.

Validation

  • The baseline reproduces the TypeError. Eleven new cases pass with the patch, covering positive and negative starts, descending and empty ranges, missing values, numeric equality, and a range larger than sys.maxsize.
  • Python 3.13.13 on Windows: 3,335 tests and doctests passed with 100% coverage. All 48 focused index cases passed on Windows 3.11, 3.12 and 3.14. Linux 3.10 passed 132,678 comparisons against list behavior.
  • Ruff lint/format, mypy, chaining stub freshness, strict Sphinx, sdist/wheel builds and diff checks passed.

OpenAI Codex (GPT-6 based) assisted with investigation, implementation, testing and drafting.

@coveralls

coveralls commented Nov 13, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — Gambit-Checkmate:fix/index-of-range-start into dgilland:develop

@dgilland
dgilland merged commit 8493b50 into dgilland:develop Nov 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

index_of raises TypeError for range sequences

3 participants